home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Turnbull China Bikeride
/
Turnbull China Bikeride - Disc 2.iso
/
STUTTGART
/
LANG
/
C
/
LIB
/
UNIXLIB37B
/
!UnixLib37
/
src
/
unix
/
c
/
access
next >
Wrap
Text File
|
1996-11-09
|
1KB
|
68 lines
/****************************************************************************
*
* $Source: /unixb/home/unixlib/source/unixlib37/src/unix/c/RCS/access,v $
* $Date: 1996/10/30 21:59:01 $
* $Revision: 1.2 $
* $State: Rel $
* $Author: unixlib $
*
* $Log: access,v $
* Revision 1.2 1996/10/30 21:59:01 unixlib
* Massive changes made by Nick Burret and Peter Burwood.
*
* Revision 1.1 1996/04/19 21:35:27 simon
* Initial revision
*
***************************************************************************/
static const char rcs_id[] = "$Id: access,v 1.2 1996/10/30 21:59:01 unixlib Rel $";
#include <errno.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/os.h>
int
access (const char *file, int mode)
{
int r[6];
_kernel_oserror *e;
int i;
char *f;
f = __uname ((char *)file, 0);
if (e = os_file (0x05, f, r))
{
__seterr (e);
return (-1);
}
switch (r[0])
{
default:
errno = ENOENT;
return (-1);
case 1:
i = ((r[5] & 0040) >> 4) | ((r[5] & 0020) >> 2) |
((r[5] & 0002)) | ((r[5] & 0001) << 2);
if (i & 0002)
i |= 0001;
if ((i & mode) != mode)
{
errno = EPERM;
return (-1);
}
return (0);
case 2:
case 3:
return (0);
/* DIR / Image */
}
}